import request from '/@/utils/request'
/**
 * 订单模块接口
 * @method getList 订单列表
 * @method getStatistics 获取数据统计
 * @method createOrder 创建订单
 * @method addMoney 回款
 * @method addMoneyRule 添加回款规则
 * @method moneyList 回款规则列表
 * @method editMoneyRule 修改回款规则
 * @method delMoneyRule 删除回款规则
 * @method getDetail 获取订单详情
 * @method createDraft 添加草稿
 * @method getDraft 获取草稿详情
 * @method delDraft 删除草稿详情
 * @method editDraft 编辑草稿
 * @method cancelOrder 取消订单
 * @method signForOrder 签收订单
 * @method verifyOrder 核销订单
 */
 export function useOrderApi() {
	return {
		getList: (params?: object) => {
			return request({
				url: '/oms/order/list',
				method: 'get',
				params,
			})
		},
		getStatistics: (params?:object) => {
			return request({
				url: '/oms/order/dataStatistics',
				method: 'get',
				params
			})
		},
		createOrder: (params?:object) => {
			return request({
				url: '/oms/order/createOrder',
				method: 'post',
				data: params
			})
		},
		addMoney: (params?:object) => {
			return request({
				url: '/oms/returned/addMoney',
				method: 'post',
				data: params
			})
		},
		addMoneyRule: (params?:object) => {
			return request({
				url: '/oms/moneyRule',
				method: 'post',
				data: params
			})
		},
		moneyList: (params?:object) => {
			return request({
				url: '/oms/moneyRule/list',
				method: 'get',
				params
			})
		},
		editMoneyRule: (params?:object) => {
			return request({
				url: '/oms/moneyRule',
				method: 'put',
				data: params
			})
		},
		delMoneyRule: (params?:string) => {
			return request({
				url: `/oms/moneyRule/${params}`,
				method: 'delete'
			})
		},
		getDetail: (params?:string) => {
			return request({
				url: '/oms/order/' + params,
				method: 'get'
			})
		},
		createDraft: (params?:string) => {
			return request({
				url: '/oms/drafts/add',
				method: 'post',
				data: params
			})
		},
		getDraftDetail: (params?:object) => {
			return request({
				url: '/oms/drafts/getInfo',
				method: 'get',
				params
			})
		},
		editDraft: (params?:object) => {
			return request({
				url: '/oms/drafts/edit',
				method: 'post',
				data: params
			})
		},
		cancelOrder: (params?:object) => {
			return request({
				url: '/oms/order/cancel',
				method: 'get',
				params
			})
		},
		signForOrder: (params?:object) => {
			return request({
				url: '/oms/delivery/signForOrder',
				method: 'get',
				params
			})
		},
		delDraft: (params?:string) => {
			return request({
				url: `/oms/drafts/${params}`,
				method: 'get'
			})
		},
		verifyOrder: (params?:string) => {
			return request({
				url: '/oms/order/destroy',
				method: 'post',
				data: params
			})
		},
		afterSale: (params?:string) => {
			return request({
				url: '/oms/order/afterSale',
				method: 'post',
				data: params
			})
		},
		sendDelivery: (params?:string) => {
			return request({
				url: '/oms/delivery/consignment',
				method: 'post',
				data: params
			})
		},
		queryDelivery: (params?:string) => {
			return request({
				url: '/oms/delivery/queryExpress',
				method: 'post',
				data: params
			})
		},
		/**
		 * 获取客户收货地址列表
		 */
		getCustomerAddrList(customerId) {
			return request({
				url: '/oms/order/getCustomerAddrList?customerId=' + customerId,
				method: 'get'
			})
		},
		/**
		 * 获取订单列表（不分页）
		 */
		getMyOrders(data) {
			return request({
				url: '/oms/order/getMyOrders',
				method: 'get',
				data
			})
		},
		/**
		 * 根据订单id获取订单信息和订单项
		 */
		getOrderInfo(orderId) {
			return request({
				url: 'oms/order/getOrderInfo?orderId=' + orderId,
				method: 'get'
			})
		}
	};
}
